let ipt_account=document.getElementById("ipt_account");
let ipt_password=document.getElementById("ipt_password");
let ipt_cfm_password=document.getElementById("ipt_cfm_password");

function save(){
	let account=ipt_account.value;
	let password=ipt_password.value;
	let cfm_password=ipt_cfm_password.value;
	console.log(account);
	if(account.trim().length===0){
		alert("请输入账号");
		return;
	}
	if(password.trim().length<6){
		alert("密码至少要求6位");
		return;
	}
	if (password!==cfm_password) {
		alert("两次密码必须一致");
		return;
	}
	let users=JSON.parse(localStorage.getItem("users"));
	if (!users) {
		users=new Array();
	}
	for (let index in users) {
		let item=users[index];
		if (item.account===account) {
			alert("该账号以被注册");
			return;
		}
	}
		users.push({account,password});
		localStorage.setItem("users",JSON.stringify(users));
		alert("注册成功");
		location.href="login.html";
}